//
//  CatalogSQL.h
//  readNovels
//
//  Created by 吳瀾洲 on 2020/4/27.
//  Copyright © 2020 wulanzhou. All rights reserved.
//

#ifndef CatalogSQL_h
#define CatalogSQL_h

//目录sql操作

//新增
#define insert_catalog_sql  @"insert into catalog(book_id,serial_number,name,page_url,sort,memo,ctime,mtime) values(?,?,?,?,?,?,?,?)"

//修改
#define update_catalog_url      @"update catalog set page_url=? where id=?"

//删除
#define delete_catalog_book_id      @"delete from catalog where book_id=?"

//查询
#define query_all_catalog         @"select * from catalog order by sort asc"
#define query_id_catalog          @"select * from catalog where id = ?"
#define query_unfinished_catalog  @"select c.* from catalog   c inner  join chapter g on c.id=g.catalog_id and g.finished=0 where c.book_id=?\
 union\
 select * from catalog where book_id=? and not exists(select 1 from chapter where catalog_id=catalog.id)"

#endif /* CatalogSQL_h */
